#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Text;

namespace Osh
{
	public class Log
	{
		public static void Exception(TraceSource traceSource, Exception e)
		{
			Write(traceSource, TraceEventType.Error, 0, e.Message);
		}

		public static void Exception(TraceSource traceSource, Exception e, string message, params object[] args)
		{
			Write(traceSource, TraceEventType.Error, 0, string.Format(message, args) + " " + e.ToString());
		}

		public static void Error(TraceSource traceSource, string message, params object[] args)
		{
			Write(traceSource, TraceEventType.Error, message, args);
		}

		public static void Warning(TraceSource traceSource, string message, params object[] args)
		{
			Write(traceSource, TraceEventType.Warning, message, args);
		}

		public static void Info(TraceSource traceSource, string message, params object[] args)
		{
			Write(traceSource, TraceEventType.Information, message, args);
		}

		public static void Write(TraceSource traceSource, string message, params object[] args)
		{
			Write(traceSource, TraceEventType.Verbose, message, args);
		}

		public static void Write(TraceSource traceSource, TraceEventType eventType, string message, params object[] args)
		{
			Write(traceSource, eventType, 0, message, args);
		}

		public static void Write(TraceSource traceSource, TraceEventType eventType, int id, string message, params object[] args)
		{
			traceSource.TraceEvent(eventType, id, GetTracePrefix() + message, args);
		}

		private static string GetTracePrefix()
		{
			return string.Empty;
			//return "[" + DateTime.Now.ToString("") + "] [" +
			//    System.Threading.Thread.CurrentThread.GetHashCode().ToString("d4", CultureInfo.InvariantCulture) + "] ";
		}
	}
}
